
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
create view [dbo].[organismo] as
SELECT distinct organismo_id_sarrhh as organismo_id, --idSubOrganizacion as organismo_id, 
o.nombre as org_nombre, --descripcion as org_nombre,
so.tipo as tab_tipo_org_id--tipo as tab_tipo_org_id
from tb_SubOrganizaciones so, tb_Organizaciones o
where so.Org = o.idOrganizaciones 
UNION
SELECT idorganismo as organismo_id,
descripcion as org_nombre,
tipoOrganismo as tab_tipo_org_id
from tb_organismos where idOrganismo not in (select organismo_id_sarrhh from tb_SubOrganizaciones)
GO
